<?
		include("dbconn.inc");
		include("dbfuc.inc");
		include("session.inc");		
		$adminuser=$_SESSION["adminuser"];
		$adminid=$_SESSION["adminid"];		
		
	if(session_is_registered("adminuser") )
	{
	
?>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style19 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #666666; }
.style20 {font-size: x-small;
	font-weight: bold;
	color: #000000;
}
.style23 {
	color: #000000;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: x-small;
	font-weight: bold;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<?
		if(($adminuser!="") && (($adminid!="") || ($adminid!=0)))
		{
			$sql="";

			$transfer_points=$_SESSION["transfer_points"];
			$tran_user=$_SESSION["tran_user"];
			$id=$_SESSION["id"];
			
			$sql="select N_POINT from POINT_MASTER where N_ID=$adminid ";
			$result=mysql_query($sql);
			$rownum=mysql_num_rows($result);
			if($rownum >0)
			{
				$rownum=$rownum-1;
				$transfer_user_point=mysql_result($result,$rownum,"N_POINT");
			
			}

			$sql="select N_POINT from POINT_MASTER where N_ID=$id ";
			$result=mysql_query($sql);
			$rownum=mysql_num_rows($result);
			if($rownum >0)
			{
				$rownum=$rownum-1;
				$recevied_user_point=mysql_result($result,$rownum,"N_POINT");
				$existinpointmaster_flag=true;
			
			}
			
			//new member values are inserting to the master table
			if($existinpointmaster_flag)
			{
				$recevied_user_point=$recevied_user_point+$transfer_points;
				$sqlpoint_master="update point_master set n_id='$id',n_point='$recevied_user_point' where n_id='$id'";				
			}
			else
			{
				$sqlpoint_master="insert into point_master(n_id,n_point) values ('$id','$transfer_points')";
			}
			$transfer_user_point=$transfer_user_point-$transfer_points;
			$sqlpoint_master_update="update point_master set n_point='$transfer_user_point' where n_id='$adminid'";
			$sqlpoint_transcation_credit="insert into transcation_details(N_FROM_ID,N_TO_ID,C_TRAN_TYPE,N_VOUCHUR,N_AMOUT,N_DEDUCTION,D_DATE) values ('$adminid','$id','CREDIT','111','$transfer_points',0,now())";
			$sqlpoint_transcation_debit="insert into transcation_details(N_FROM_ID,N_TO_ID,C_TRAN_TYPE,N_VOUCHUR,N_AMOUT,N_DEDUCTION,D_DATE) values ('$id','$adminid','DEBIT','111','$transfer_points',0,now())";
										
			mysql_query($sqlpoint_master);
			mysql_query($sqlpoint_master_update);
			mysql_query($sqlpoint_transcation_credit);
			mysql_query($sqlpoint_transcation_debit);
			
?>		
<br>
<table width="369" border="1" align="center" cellpadding="4" cellspacing="4" bordercolor="#666666">
  <tr>
    <td width="349" colspan="2" bgcolor="#F9F9F9" class="style19"><span class="style20"> Point Transfer Details:-</span></td>
  </tr>
  <tr>
    <td height="30" class="style23">Point transcation completed successfully </td>
  </tr>
</table>
</body>
</html>
<?
	}
	}
	else
	{
		$errormsg="Your session is expeired. Please login again.";
		header("location: index.php?error=$errormsg");
	}
?>	
